import sha1 from 'js-sha1';
export function validatePhoneNumber(str) {
	const reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
	return reg.test(str)
}

// 获取教育
export function getEdu(type){
	let str = ''
	let newType = type*1
	switch (newType){
		case 0:
			str = "初中及以下"
			break;
		case 1:
			str = "高中（中专）"
			break;
		case 2:
			str = "大学（本专科）"
			break;
		case 3:
			str = "硕士及以上"
			break;
		case -1:
			str = "不限学历"
			break;
		default:
			break;
	}
	return str
}
// 获取工作经验
export function getWork(type){
	let str = ''
	let newType = type*1
	switch (newType){
		case 0:
			str = "1年以内"
			break;
		case 1:
			str = "1-3年"
			break;
		case 2:
			str = "3-5年"
			break;
		case 3:
			str = "5-8年"
			break;
		case 4:
			str = "8年以上"
			break;
		case -1:
			str = "不限经验"
			break;
		default:
			break;
	}
	return str
}
// 年龄限制
export function getAge(type){
	let str = ''
	switch (type){
		case 0:
			str = "18-30岁"
			break;
		case 1:
			str = "30-40岁"
			break;
		case 2:
			str = "40以上"
			break;
		case -1:
			str = "不限年龄"
			break;
		default:
			break;
	}
	return str
}

// // 性别
// export const sexList = [
// 	{value:0,text:'男'},
// 	{value:0,text:'女'}
// ]

// 性别
export const sexList = [
	{value:0,name:'男'},
	{value:1,name:'女'}
]
//有无传染病
export const isIllnessList = [
	{value:0,name:'没有传染病'},
	{value:1,name:'有传染病'}
]

export const shortOrderStatus = [
	{value:'-2',name:'未支付'},
	{value:'01',name:'已支付'},
	{value:'0',name:'待接单'},
	{value:'1',name:'待服务'},
	{value:'2',name:'待验收'},
	{value:'3',name:'已完成'},
	{value:'4',name:'已取消'},
]



//将数组按chunkSize个重新分割
export function splitArray(array, chunkSize) {
  const result = [];
  for (let i = 0; i < array.length; i += chunkSize) {
    const chunk = array.slice(i, i + chunkSize);
    result.push(chunk);
  }
  return result;
}

// 生成与IM接口调用时需要的签名
export const gendersignToIm = () => {
	const nonce = Math.floor(Math.random() * 100) + 1;
	const timestamp = new Date().getTime();
	const SECRET_KEY = 123456;
	const sign = sha1(nonce + "|" + SECRET_KEY + "|" + timestamp);
	return {
		nonce,
		timestamp,
		sign
	}
}